#include "CloudServer.h"
#include "ui_CloudServer.h"

CloudServer::CloudServer(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::CloudServer)
{
    ui->setupUi(this);
    loadConfigFile();

    MyTcpServer::getInstance().listen(QHostAddress(QHostAddress::Any), m_Port);

}

CloudServer::~CloudServer()
{
    delete ui;
}

void CloudServer::loadConfigFile()
{
    QFile file(":/server.cfg");
    if(file.open(QIODevice::ReadOnly)){
        QByteArray data = file.readAll();
        QString strData = data;
        strData.replace("\n", " ");
        QStringList strList = strData.split(" ");
        m_strIP = strList[0];
        m_Port = strList[1].toInt();

        qDebug() << m_strIP << ":" << m_Port;
    }

}
